<template>
  <view class="visit">
    <globalNavBar title="预约人管理"/>
    <view class="container  ">
		<view class="list flex" v-for="item in list" :key="item.id">
			<view>
				<view>姓名：{{item.username}}</view>
				<view>手机号：{{item.mobile}}</view>
			</view>
			<view class="flex flex_column">
				<button size="mini" @click="updateManager(item.id)">修改</button>
				<button size="mini" @click="openModal(item.id)" style="margin-top: 10rpx;">删除</button>
			</view>
		</view>
	</view>
	<uv-modal ref="modal" title="删除" content='确定删除该预约人吗?' @confirm="deleteManager"></uv-modal>
  </view>
</template>

<script>
	import http from '@/utils/request.js'
export default {
  data() {
    return {
		list:[
			
		],
		delId:0,
    };
  },
  onLoad(options) {
	this.getList()
  },

  methods: {
	getList(){
		http.post('api/user/appointment_manager_list',{}).then((res)=>{
			this.list = res.data
		})
	},
	updateManager(id){
		uni.navigateTo({
			url:'/pages/booking/update_appointment_manager?id='+id
		})
	},
	openModal(id) {
		this.delId = id
		this.$refs.modal.open();
	},
	deleteManager(){
		http.get('api/user/delete_appointment_manager',{id:this.delId}).then(res=>{
			if(res.code == 1){
				uni.showToast({
					'title':'操作成功',
				});
				setTimeout(()=>{
					uni.navigateTo({
						url:'/pages/booking/appointment_manager'
					})
				},2000)
			}else{
				uni.showToast({
					icon:'error',
					'title':'操作失败',
				})
			}
		})
	}
  }
}
</script>

<style lang="scss" scoped>
	
	.flex {
		display: flex;
	}
	.flex_center {
		display: flex;
		justify-content: center;
	}
	.flex_wrap {
		flex-wrap: wrap;
	}
	.flex_column {
		flex-direction: column;
	}
	.mt-10 {
		margin-top: 10rpx;
	}
	.container {
		padding: 20rpx;
		.list {
			padding: 20rpx;
			margin-bottom: 20rpx;
			border:1rpx solid #eee;
			justify-content: space-between;
			align-items: center;
		}
	}
	
	
	
	
</style>
